package cn.itcast.bos.domain.user;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.GenericGenerator;

import cn.itcast.bos.domain.auth.Role;
import cn.itcast.bos.domain.qp.NoticeBill;

//import java.util.Date;

/**
 * User generated by hbm2java
 */
@Entity
@Table(name = "T_USER", schema = "ITCAST27", uniqueConstraints = @UniqueConstraint(columnNames = "USERNAME"))
@NamedQueries(value = { @NamedQuery(name = "User.login", query = "from User where username = ? and password = ?") })
public class User implements java.io.Serializable {

	private String id;
	private Date birthday;
	private String gender;
	private String password;
	private String remark;
	private Double salary;
	private String station;
	private String telephone;
	private String username;
	private Set<Role> roles = new HashSet<Role>(0);
	private Set<NoticeBill> noticeBills = new HashSet<NoticeBill>(0);

	public User() {
	}

	public User(Date birthday, String gender, String password, String remark, Double salary, String station, String telephone, String username, Set<Role> roles, Set<NoticeBill> noticeBills) {
		this.birthday = birthday;
		this.gender = gender;
		this.password = password;
		this.remark = remark;
		this.salary = salary;
		this.station = station;
		this.telephone = telephone;
		this.username = username;
		this.roles = roles;
		this.noticeBills = noticeBills;
	}

	@GenericGenerator(name = "generator", strategy = "uuid")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", unique = true, nullable = false, length = 1020)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "BIRTHDAY", length = 7)
	public Date getBirthday() {
		return this.birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	@Column(name = "GENDER", length = 1020)
	public String getGender() {
		return this.gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Column(name = "PASSWORD", length = 1020)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "REMARK", length = 1020)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "SALARY", precision = 126, scale = 0)
	public Double getSalary() {
		return this.salary;
	}

	public void setSalary(Double salary) {
		this.salary = salary;
	}

	@Column(name = "STATION", length = 1020)
	public String getStation() {
		return this.station;
	}

	public void setStation(String station) {
		this.station = station;
	}

	@Column(name = "TELEPHONE", length = 1020)
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Column(name = "USERNAME", unique = true, length = 1020)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "USER_ROLE", schema = "ITCAST27", joinColumns = { @JoinColumn(name = "USER_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID", nullable = false, updatable = false) })
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<NoticeBill> getNoticeBills() {
		return this.noticeBills;
	}

	public void setNoticeBills(Set<NoticeBill> noticeBills) {
		this.noticeBills = noticeBills;
	}

}
